package com.mldong.modules.sys.vo;

import cn.hutool.core.lang.Dict;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.mldong.tree.INode;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 前端路由对象
 * @author mldong
 * @date 2024/12/12
 */
@Data
public class RouteMenuVO implements INode {
    @JsonIgnore
    private Long id;
    @JsonIgnore
    private Long parentId;
    private String name;
    private String path;
    private String redirect;
    private String component;
    private Dict meta = Dict.create();

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<INode> children;
    @Override
    public List<INode> getChildren() {
        if(children == null) {
            children = new ArrayList<>();
        }
        return children;
    }

    @Override
    public Object getSort() {
        return meta.get("order",Long.MAX_VALUE);
    }
}
